#include <pwd.h>

aufruf:	doFile(path,argv);

	
	

bool check_user(char *name,char *parms)
{
	char *path = name;
	char *user = parms;

	struct stat buf;
        struct passwd *pPwdEntry = NULL;

        if(lstat(path, &buf) == -1)
        {
                printf("error lstat!\n");
        }
        else
        {
                //printf("user ID of owner: %d\n", buf.st_uid);
                if((pPwdEntry = getpwuid(buf.st_uid)) == NULL)
                {
                        printf("user not found!\n");
                }
                else
                {
                        //printf("user Name of owner: %s\n", pPwdEntry->pw_name);
                	if(strcmp(pPwdEntry->pw_name, user) == 0)
			{
				return true;
			}
			/* ??? */
			else if(pPwdEntry->pw_uid == buf.st_uid)
			{
                                return true;
                        }

		}
        }

	return false;
}

bool check_type(char *name,char *parms)
{
	char *path = name;
	char *type = parms;

	struct stat buf;
	
	if(lstat(path, &buf) == -1)
	{
		printf("error lstat!\n");
	}
	else
	{
		switch(type[0])
		{
			case 'b': if(S_ISBLK(buf.st_mode)) return true; break;
			case 'c': if(S_ISCHR(buf.st_mode)) return true; break;
			case 'd': if(S_ISDIR(buf.st_mode)) return true; break;
			case 'p': if(S_ISFIFO(buf.st_mode)) return true; break;
			case 'f': if(S_ISREG(buf.st_mode)) return true; break;
			case 'l': if(S_ISLNK(buf.st_mode)) return true; break;
			case 's': if(S_ISSOCK(buf.st_mode)) return true; break;
			default: return false; break;
		}
	}

	return false;
}
bool check_nouser(char *name)
{
	char *path = name;

	struct stat buf;
	struct passwd *pPwdEntry = NULL;

	if(lstat(path, &buf) == -1)
	{
		printf("error lstat!\n");
	}
	else
	{
		if(pPwdEntry = getpwuid(buf.st_uid) == NULL)
		{
			return true;
		}
	}
	return false;
}

